package com.beauty.dressing.module.mine.activity;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.TextView;

import com.framework.common.base.IBaseFragment;
import com.beauty.dressing.R;
import com.beauty.dressing.common.base.BaseFragmentActivity;
import com.beauty.dressing.common.view.LoadingNodataLayout;
import com.beauty.dressing.module.mine.adapter.FragmentAdapter;
import com.beauty.dressing.module.mine.fragment.AllOrderFragment;
import com.beauty.dressing.module.mine.fragment.CompletedOrderFragment;
import com.beauty.dressing.module.mine.fragment.WaitingClauseOrderFragment;
import com.beauty.dressing.module.mine.fragment.WaitingReceiptOrderFragment;
import com.beauty.dressing.module.mine.fragment.WaitingShippedOrderFragment;

import java.util.ArrayList;
import java.util.List;

public class MyOrderActivity extends BaseFragmentActivity {
    private LoadingNodataLayout mNodtaLayout;

    private List<IBaseFragment> fragments = new ArrayList<>();

    private List<String> titles = new ArrayList<>();

    ViewPager mVpLessonView;

    private FragmentAdapter adapter;
    private TabLayout mTabView;

    @Override
    public void setContentView() {
        setContentView(R.layout.activity_my_orders);
    }

    @Override
    public void findView() {
        TextView title_txt = (TextView) findViewById(R.id.title_txt);
        title_txt.setText("我的订单");
        findViewById(R.id.left_img_btn).setOnClickListener(this);
        mTabView = (TabLayout) findViewById(R.id.tabView);
        mVpLessonView = (ViewPager) findViewById(R.id.vpLessonView);

    }

    @Override
    public void initData() {
        if (adapter == null) {
            fragments.add(new AllOrderFragment());
            fragments.add(new WaitingClauseOrderFragment());
            fragments.add(new WaitingShippedOrderFragment());
            fragments.add(new WaitingReceiptOrderFragment());
            fragments.add(new CompletedOrderFragment());
            titles.add("全部");
            titles.add("待付款");
            titles.add("待发货");
            titles.add("待收货");
            titles.add("已完成");
            adapter = new FragmentAdapter(context.getSupportFragmentManager(), fragments, titles);
            mVpLessonView.setAdapter(adapter);
            mTabView.setupWithViewPager(mVpLessonView);
            mTabView.setTabMode(TabLayout.MODE_FIXED);
            if (getIntent().getIntExtra("Status", -1) != -1) {
                mTabView.getTabAt(getIntent().getIntExtra("Status", -1)).select();
            }
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.left_img_btn:
                this.finish();
                break;
        }
    }

}
